September Listing 3
         TTL "Listing Three: S/A Mini-Mailer"
;
;  Listing 3
;
;
;
;  WARNING!!! This program is intended  for demonstration
;  purposes only. It has not been tested well enough
;  to quality it as a commercial product.
;  Neither Lazerware nor Randy Hyde can assume any
;  responsibility for the use of this program.
;
;
;
;
**********************************
*                                *
* SPEED/ASM Equates              *
*                                *
**********************************
;
;
;
;
;
;
*************
* CONSTANTS *
*************
;
FALSE    EQU 0
TRUE     EQU 1
CR       EQU $8D
BELL     EQU $87
CTLD     EQU $84
;
;
EQ       EQU "="
NE       EQU "#"
GT       EQU ">"
LT       EQU "<"
GE       EQU ">"|"="*256
LE       EQU "<"|"="*256
;
;
;
;
;
;
;
**************************
* SPEED/ASM ENTRY POINTS *
**************************
;
PUTC     EQU $7800
GETC     EQU PUTC+3
SAGL     EQU GETC+3          ;FOR USE  BY S/A  ONLY-SEE DO
SAPC     EQU SAGL+3          ; "   "    "  "    "     "   
HOME     EQU SAPC+3          ;HOME AND CLEAR
READLN   EQU HOME+3
INIT     EQU READLN+3
FOR      EQU INIT+3
FOR0     EQU FOR+3
NEXT     EQU FOR0+3
IFI      EQU NEXT+3
IFI0     EQU IFI+3
IFS      EQU IFI0+3
IFS0     EQU IFS+3
MOVE     EQU IFS0+3
LOAD     EQU MOVE+3
MOVS     EQU LOAD+3
LDSTR    EQU MOVS+3
PRINT    EQU LDSTR+3
PRTSTR   EQU PRINT+3
PRTINT   EQU PRTSTR+3
RDSTR    EQU PRTINT+3
RDINT    EQU RDSTR+3
ONXGOTO  EQU RDINT+3
CASE     EQU ONXGOTO+3
CASEI    EQU CASE+3
INSET    EQU CASEI+3
NOTINSET EQU INSET+3
ABS      EQU NOTINSET+3
NEG      EQU ABS+3
MUL      EQU NEG+3
DIV      EQU MUL+3
MOD      EQU DIV+3
RND      EQU MOD+3
SUBSTR   EQU RND+3
INDEX    EQU SUBSTR+3
LENGTH   EQU INDEX+3
CONCAT   EQU LENGTH+3
;
;  Apple Monitor equates.
;   
EXIT     EQU $FF69
;
;
;
;
**********************************
;
;
;  SPEED/ASM mini-mailing list pgm.
;
;
;
;  This program demonstrates a practical
;  application of the SPEED/ASM routines
;  running under Apple DOS.
;
;   
;  This section of code provides the
;  input module. The following information
;  is read in and written to the disk.
;
;
;  First name: 13 characters.
;  Last name:  13 characters.
;  C/O:        25 characters.
;  Street:     31 characters.
;  City:       15 characters.
;  State:       4 characters.
;  Zipcode:    11 characters.
;  Phone:      16 characters.
;
;
;
**********************************
*
*
*  SPEED/ASM initialization and
*  title page.
*
**********************************
;
;
BEGIN    JSR INIT            ; Always before using SPEED/A
;
;
;
**********************************
*
*  Mini-Mailer Main Loop
*
**********************************
;
;
;
;
         JSR PRINT
         BYT CR,CR,"Insert disk with the MAIL.LIST",CR
         BYT "(if you have one) into the active drive",CR
         BYT "and press return: ",0
         JSR READLN
;
         JSR PRINT
         BYT CR,CTLD,"OPEN MAIL.LIST,L128",CR
         BYT CTLD,"NOMON O,I,C",CR,0
;
;
;
;
MAINLOOP JSR HOME
         JSR PRINT
         BYT CR,CR,"SPEED/ASM Mini-Mailing List Program",CR,CR
         BYT "Input Module:",CR,CR
         BYT "    A) add records",CR
         BYT "    D) Delete a record",CR
         BYT "    O) Open a new file",CR
         BYT "    P) Print file",CR
         BYT CR
         BYT "    Q) Quit",CR,CR
         BYT "Choice: ",0
;
;
;
;
;  READLN(INPUTSTR);
;
         JSR READLN
         JSR RDSTR
         ADR INPUTSTR
;
;
;  IF (INPUTSTR = "A") OR (INPUTSTR = "a") THEN
;       GOTO ADDRECS;
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "A",0
         BTR ADDRECS
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "a",0
         BTR ADDRECS
         JMP TSTFORD
;
;
;
;
         TTL "Mini-Mailing List:  Add Module"
;
;
;
;
**********************************
;
;
;  Handle the "A" option here.
;
ADDRECS  JSR HOME
         JSR PRINT
         BYT CR,CR
         BYT "Add records module:",CR,CR,0
;
;
;
;
NOERROR  JSR PRINT
         BYT CR,CTLD,"READ MAIL.LIST,R0,B0",CR,0
;   
;  Read in the number of records in this
;  file into NUMRECS.
;
         JSR READLN
         JSR RDINT
         ADR NUMRECS
         JSR PRINT           ;Turn off read cmd.
         BYT CR,CTLD,CR,0
;
;
;
;
;
;  Get the information to write to
;  the file.
;
GETFNAME JSR PRINT
         BYT CR,"Enter First name: ",0
         JSR READLN
         JSR RDSTR
         ADR FIRSTNAM
         BVC GETLNAME
;
         JSR PRINT
         BYT CR,BELL,"Re-enter first name",CR,0
         JMP GETFNAME
;
;
;
GETLNAME JSR PRINT
         BYT CR,"Enter Last name: ",0
         JSR READLN
         JSR RDSTR
         ADR LASTNAME
         BVC GETAUX
;
         JSR PRINT
         BYT CR,BELL,"Re-enter last name",CR,0
         JMP GETLNAME
;
;
;
GETAUX   JSR PRINT
         BYT "Enter auxiliary info: ",0
         JSR READLN
         JSR RDSTR
         ADR AUXINFO
         BVC GETSTRT
;
         JSR PRINT
         BYT CR,BELL,"Re-enter Auxiliary information",CR,0
         JMP GETAUX
;
;
;
GETSTRT  JSR PRINT
         BYT CR,"Enter street address: ",0
         JSR READLN
         JSR RDSTR
         ADR STRTADRS
         BVC GETCITY
;
         JSR PRINT
         BYT CR,BELL,"Re-enter street Address",CR,0
         JMP GETSTRT
;
;
;
GETCITY  JSR PRINT
         BYT CR,"Enter city: ",0
         JSR READLN
         JSR RDSTR
         ADR CITY
         BVC GETSTATE
;
         JSR PRINT
         BYT CR,BELL,"Re-enter city",CR,0
         JMP GETCITY
;
;
;
GETSTATE JSR PRINT
         BYT CR,"Enter state: ",0
         JSR READLN
         JSR RDSTR
         ADR STATE
         BVC GETZIP
;
         JSR PRINT
         BYT CR,BELL,"Re-enter State",CR,0
         JMP GETSTATE
;
;
;
GETZIP   JSR PRINT
         BYT CR,"Enter Zipcode: ",0
         JSR READLN
         JSR RDSTR
         ADR ZIPCODE
         BVC GETPHONE
;
         JSR PRINT
         BYT CR,BELL,"Re-enter zipcode",CR,0
         JMP GETZIP
;
;
;
GETPHONE JSR PRINT
         BYT CR,"Enter Phone #: ",0
         JSR READLN
         JSR RDSTR
         ADR PHONENUM
         BVC WRTINFO
;
         JSR PRINT
         BYT CR,BELL,"Re-enter Phone number",CR,0
         JMP GETPHONE
;
;
;
WRTINFO  CLC 
         LDA NUMRECS
         ADC #1
         STA RECNUM
         LDA NUMRECS+1
         ADC /1
         STA RECNUM+1
;
;
;  PRINT CHR$(4) ;"WRITE MAIL.LIST,R"; RECNUM; ",B0"
;
         JSR PRINT
         BYT CR,CTLD,"WRITE MAIL.LIST,R",0
         JSR PRTINT
         ADR RECNUM
         JSR PRINT
         BYT ",B0",CR,0
;
;
         JSR PRTSTR
         ADR FIRSTNAM
         JSR WRITELN
;
         JSR PRTSTR
         ADR LASTNAME
         JSR WRITELN
;
         JSR PRTSTR
         ADR AUXINFO
         JSR WRITELN
;
         JSR PRTSTR
         ADR STRTADRS
         JSR WRITELN
;
         JSR PRTSTR
         ADR CITY
         JSR WRITELN
;
         JSR PRTSTR
         ADR STATE
         JSR WRITELN
;
         JSR PRTSTR
         ADR ZIPCODE
         JSR WRITELN
;
         JSR PRTSTR
         ADR PHONENUM
         JSR WRITELN
;
;
;  Turn off output to the file.
;
         JSR PRINT
         BYT CTLD,CR,0
;   
;  NUMRECS = RECNUM (Which contains NU MRECS+1 )
;   
         JSR MOVE
         ADR RECNUM,NUMRECS
;
;
GETYORNO JSR PRINT
         BYT CR,CR,"Add another record? (Y/N): ",0
         JSR READLN
         JSR RDSTR
         ADR INPUTSTR
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "N",0
         BTR EXITADD
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "y",0
         BTR EXITADD
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "Y",0
         BTR DOAGAIN
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "y",0
         BFL GETYORNO
;
DOAGAIN  JMP GETFNAME
;
;
;  Before exiting, update the record
;  count
;
EXITADD  JSR PRINT
         BYT CR,CTLD,"WRITE MAIL.LIST,R0,B0",CR
         BYT 0
;
;
         JSR PRTINT
         ADR NUMRECS
         JSR PRINT
         BYT "    ",CR,CTLD,CR,0
         JMP MAINLOOP
;
;
;
;
;
;
         TTL "Mini-Mailer: Delete Module"
;
**********************************
;
;
TSTFORD  JSR IFS0
         ADR INPUTSTR,EQ
         BYT "D",0
         BTR ISD
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "d",0
         BTR ISD
         JMP TSTFOR0
;
ISD      JSR PRINT
         BYT CR,CR,"Delete which record? ",0
         JSR READLN
         JSR RDINT
         ADR RECNUM
         BVC GOODNUM
;
         JSR PRINT
         BYT CR,BELL,"Illegal record number, re-enter",CR,0
         JMP TSTFORD
;
;
;  See if this is a valid record number.
;
GOODNUM  JSR PRINT
         BYT CR,CTLD,"READ MAIL.LIST,R0,B0",CR,0
         JSR READLN
         JSR RDINT
         ADR NUMRECS
;
         JSR IFI
         ADR RECNUM,LE,NUMRECS
         BTR RECOK
;
         JSR PRINT
         BYT CR,"That record doesn't exist",CR
         BYT CR,"Press return to continue:",0
         JSR READLN
         JMP MAINLOOP
;
RECOK    JSR PRINT
         BYT CR,CTLD,"WRITE MAIL.LIST,R",0
         JSR PRTINT
         ADR RECNUM
         JSR PRINT
         BYT ",B0",CR
         BYT $80,CR
         BYT CTLD,CR,0
;
         JSR PRINT
         BYT CR,CR,"Deleted",CR
         BYT "Press return to continue:",0
         JSR READLN
         JMP MAINLOOP
;
;
;
         TTL "Mini-Mailer: Status Module"
;
;
**********************************
;
;
TSTFORS  JSR IFS0
         ADR INPUTSTR,EQ
         BYT "S",0
         BTR ISS
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "s",0
         BTR ISS
         JMP TSTFOR0
;
;
ISS      JSR PRINT
         BYT CR,CTLD,"READ MAIL.LIST,R0,B0",CR,0
         JSR READLN
         JSR RDINT
         ADR NUMRECS
;
         JSR PRINT
         BYT CR,"There are ",0
         JSR PRTINT
         ADR NUMRECS
;
         JSR PRINT
         BYT " records in the file",CR,CR
         BYT "Press return to continue:",0
         JSR READLN
         JMP MAINLOOP
;
;
;
         TTL "Mini-Mailer: New File Module"
;
;
**********************************
;
;
TSTFOR0  JSR IFS0
         ADR INPUTSTR,EQ
         BYT "O",0
         BTR IS0
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "o",0
         BTR IS0
         JMP TSTFORP
;
;
IS0      JSR PRINT
         BYT CR,"Is the previous disk still",CR
         BYT "in the drive? (Y/N): ",0
         JSR READLN
         JSR RDSTR
         ADR INPUTSTR
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "Y",0
         BTR ISYES
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "y",0
         BTR ISYES
;
         JSR PRINT
         BYT CR,BELL,"Put the previous disk back into",CR
         BYT "the active drive before continuing",CR,0
         JMP IS0
;
;
ISYES    JSR PRINT
         BYT CR,CTLD,"CLOSE",CR,0
;
         JSR PRINT
         BYT CR,"Place the diskette you wish to create",CR
         BYT "a ""MAIL.LIST"" file on into the active",CR
         BYT "disk drive",CR
         BYT "and press return: ",0
;
         JSR READLN
         JSR PRINT
         BYT CR,CTLD,"OPEN MAIL.LIST,L128",CR
         BYT CTLD,"WRITE MAIL.LIST",CR
         BYT "0      ",CR
         BYT CTLD,CR,0
;
;
         JSR PRINT
         BYT CR,"All done, press return to continue:",0
         JSR READLN
         JMP MAINLOOP
;
;
;
         TTL "Mini-Mailer: Print Module "
;
;
**********************************
;
;
TSTFORP  JSR IFS0
         ADR INPUTSTR,EQ
         BYT "P",0
         BTR ISP
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "p",0
         BTR ISP
         JMP TSTFORQ
;
;
ISP      JSR PRINT
         BYT CR,"Send output to what slot?",CR
         BYT "(zero for screen): ",0
         JSR READLN
         JSR RDINT
         ADR I
;
;
         JSR PRINT
         BYT CR,CTLD,"READ MAIL.LIST,R0,B0",CR,0
         JSR READLN
         JSR RDINT
         ADR NUMRECS
;
         JSR PRINT
         BYT CR,CTLD,"PR#",0
         JSR PRTINT
         ADR I
         JSR WRITELN
;
;
;
;  FOR I = 1 TO NUMRECS STEP 1
;
         JSR FOR
         ADR I,ONE,NUMRECS,ONE
;
         JSR PRINT
         BYT CTLD,"READ MAIL.LIST,B0,R",0
         JSR PRTINT
         ADR I
         JSR WRITELN
;
         JSR READLN
         JSR RDSTR
         ADR FIRSTNAM
;   
;  Check to see if this is a deleted ,
;  record or not.
;
         JSR IFS0
         ADR FIRSTNAM,EQ
         BYT $80,0
         BFL NOTDLTD
         JMP NEXTP
;
;
NOTDLTD  JSR READLN
         JSR RDSTR
         ADR LASTNAME
;
         JSR READLN
         JSR RDSTR
         ADR AUXINFO
;
         JSR READLN
         JSR RDSTR
         ADR STRTADRS
;
         JSR READLN
         JSR RDSTR
         ADR CITY
;
         JSR READLN
         JSR RDSTR
         ADR STATE
;
         JSR READLN
         JSR RDSTR
         ADR ZIPCODE
;
         JSR READLN
         JSR RDSTR
         ADR PHONENUM
;
;
         JSR PRTSTR
         ADR LASTNAME
         JSR PRINT
         BYT ", ",0
         JSR PRTSTR
         ADR FIRSTNAM
         JSR WRITELN
;
         JSR PRTSTR
         ADR AUXINFO
         JSR WRITELN
;
         JSR PRTSTR
         ADR STRTADRS
         JSR WRITELN
;
         JSR PRTSTR
         ADR CITY
         JSR PRINT
         BYT ", ",0
         JSR PRTSTR
         ADR STATE
         JSR PRINT
         BYT "  ",0
         JSR PRTSTR
         ADR ZIPCODE
         JSR WRITELN
;
         JSR PRTSTR
         ADR PHONENUM
         JSR WRITELN
         JSR WRITELN
         JSR WRITELN
;
NEXTP    JSR NEXT
;
;
         JSR PRINT
         BYT CR,CTLD,"PR#0",CR
         BYT CR,CR
         BYT "Press return to continue:",0
         JSR READLN
         JMP MAINLOOP
;
;
;
;
         TTL "Auxiliary routines, etc."
;
;
TSTFORQ  JSR IFS0
         ADR INPUTSTR,EQ
         BYT "Q",0
         BTR QUIT
;
         JSR IFS0
         ADR INPUTSTR,EQ
         BYT "q",0
         BTR QUIT
;
         JSR PRINT
         BYT CR,BELL,BELL,BELL,0
         JMP MAINLOOP
;
;
QUIT     JSR PRINT
         BYT CR,"Make sure the disk with the MAIL.LIST",CR
         BYT "file is still in the active disk drive",CR
         BYT "and press return:",0
         JSR READLN
;
         JSR PRINT
         BYT CR,CTLD,"CLOSE",CR,0
         JMP EXIT
;
;
;
;
;
;
**********************************
;
;  Auxiliary routines.
;
WRITELN  LDA #CR
         JMP PUTC
;
;
;
**********************************
;
;
;  Variable declarations.
;
;
;
;
ONE      ADR 1
;
;
;
I        ADR 0
NUMRECS  ADR 0
RECNUM   ADR 0
;
;
INPUTSTR ADR 128
         DFS 128
FIRSTNAM ADR 11
         DFS 11
;
LASTNAME ADR 11
         DFS 11
;
AUXINFO  ADR 23
         DFS 23
;
STRTADRS ADR 29
         DFS 29
;
CITY     ADR 13
         DFS 13
;
STATE    ADR 2
         DFS 2
;
ZIPCODE  ADR 9
         DFS 9
;
PHONENUM ADR 14
         DFS 14
;
;
         END